package com.muyu.danmo.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.danmo.service.AfterSalesService;
import com.muyu.system.domain.Vo.AfterSalesDetailVO;
import com.muyu.system.domain.dto.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 售后
 * @author Administrator
 */
@RestController
@RequestMapping("/after/sales")
@RequiredArgsConstructor
public class AfterSalesController {


    private final AfterSalesService afterSalesService;




    /**
     * 新增售后
     * @param afterSalesAddDTO
     * @return
     */
    @PostMapping("/add")
    public Result<String> add(@RequestBody @Valid AfterSalesAddDTO afterSalesAddDTO){
        afterSalesService.add(afterSalesAddDTO);
        return Result.success();
    }


    /**
     * 取消售后
     * @param afterSalesDeleteDTO
     * @return
     */
    @PostMapping("/delete")
    public Result<String> delete(@RequestBody @Valid AfterSalesDeleteDTO afterSalesDeleteDTO){
        afterSalesService.delete(afterSalesDeleteDTO);
        return Result.success();
    }


    /**
     * 售后详情
     * @param afterSalesAddDTO
     * @return
     */
    @PostMapping("/detail")
    public Result<AfterSalesDetailVO> detail(@RequestBody @Valid AfterSalesDeleteDTO afterSalesAddDTO){
        AfterSalesDetailVO detail = afterSalesService.detail(afterSalesAddDTO);
        return Result.success(detail);

    }

    /**
     * 退款的快递信息提交
     * @return
     */
    @PostMapping("/courier")
    public Result<String> courier(@RequestBody @Valid CourierDTO courierDTO) {
        afterSalesService.courier(courierDTO);
        return Result.success();
    }



    /**
     * 商家确认收货
     * @return
     */
    @PostMapping("/seller/receiving")
    public Result<String> receiving(@RequestBody @Valid SellerReceivingDTO sellerReceivingDTO){
        afterSalesService.receiving(sellerReceivingDTO);
        return Result.success();
    }


    /**
     * 商家审核
     * @param merchantAuditDTO
     * @return
     */
    @PostMapping("/merchant/audit")
    public Result<String>merchantAudit(@RequestBody  @Valid MerchantAuditDTO merchantAuditDTO){
        afterSalesService.merchantAudit(merchantAuditDTO);
        return Result.success();
    }







}
